#pragma once
#include "event_handler.h"
#include <functional>

/// 监听 socket 的处理器，负责 accept 并分发新连接
class Acceptor : public EventHandler {
public:
    using NewConnectionCallback = std::function<void(int)>;

    Acceptor(EventLoop& loop, int listenFd);

    void setNewConnectionCallback(NewConnectionCallback cb) {
        newConnectionCallback_ = std::move(cb);
    }

    void handleEvent(uint32_t events) override;

private:
    NewConnectionCallback newConnectionCallback_;
};